package com.thon.service.user.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thon.dao.user.CouponDao;
import com.thon.dao.util.Page;
import com.thon.entity.user.Coupon;
import com.thon.service.user.CouponService;

@Service
@Transactional
public class CouponServiceImpl implements CouponService {

	@Autowired
	private CouponDao couponDao;
	
	@Override
	public Page<Coupon> listCoupon(Page<Coupon>page,int uid) {
		return couponDao.listUnusedCoupon(uid, page);
	}
	
	@Override
	public Page<Coupon> listUsedCoupon(Page<Coupon>page,int uid) {
		return couponDao.listUsedCoupon(page, uid);
	}

	@Override
	public Coupon getCoupon(int id, String no) {
		return couponDao.getCoupon(id,  no);
	}

	@Override
	public Coupon getCouponById(int id) {
		return couponDao.get(id);
	}

	@Override
	public void update(Coupon coupon) {
		couponDao.update(coupon);
	}

	@Override
	public void save(Coupon coupon) {
		couponDao.save(coupon);
	}

	@Override
	public List<Coupon> listAll() {
		return couponDao.listAll();
	}

	@Override
	public Page<Coupon> findCouponByStatus(String value, int id, int pageNo, int pageSize) {
		
		Page<Coupon> page = new Page<Coupon>();
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);
		page = couponDao.findCouponByStatus(page,  value,  id);
		return page;
	}

	@Override
	public Page<Coupon> findCouponByType(String type, int id, int pageNo,int pageSize) {
		Page<Coupon> page = new Page<Coupon>();
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);
		page = couponDao.findCouponByType(page, type, id);
		return page;
	}

	@Override
	public Page<Coupon> findCouponByTime(String overdueDt, int id, int pageNo,int pageSize) {
		Page<Coupon> page = new Page<Coupon>();
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);
		page = couponDao.findCouponByTime(page, overdueDt, id);
		return page;
	}

	@Override
	public Page<Coupon> findCouponByCreateDt(String createDt, int id, int pageNo,
			int pageSize) {
		Page<Coupon> page = new Page<Coupon>();
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);
		page = couponDao.findCouponByCreateDt(page, createDt, id);
		return page;
	}

	@Override
	public void del(Coupon oldCoupon) {
		couponDao.delete(oldCoupon);
	}

	@Override
	public void sendText(Coupon coupon) {
	}

	@Override
	public Page<Coupon> findCouponPages(Page<Coupon> page) {
		return couponDao.findCouponPages(page);
	}

	@Override
	public Page<Coupon> findCouponByProjectId(Page<Coupon> page, int id,int projectId) {
		
		return couponDao.findCouponByProjectId(page, projectId, id);
	}

	@Override
	public Page<Coupon> findAllCoupons(Page<Coupon> page, int uid) {
		
		return couponDao.findAllCoupons(page, uid);
	}

	@Override
	public Long countUnusedCoupon(Integer uid) {
		
		return couponDao.countUnusedCoupon(uid);
	}

	@Override
	public Page<Coupon> findAllCoupons(Page<Coupon> page) {
		
		return couponDao.findAllCoupons(page);
	}

	@Override
	public Page<Coupon> findCouponByStatus(Page<Coupon> page, String status) {
		
		return couponDao.findCouponByStatus(page, status);
	}

	@Override
	public Page<Coupon> findCouponByType(Page<Coupon> page, String type) {
		
		return couponDao.findCouponByType(page, type);
	}

	@Override
	public List<Coupon> listByStatus(String status) {
		return couponDao.listByStatus( status);
	}
	
	@Override
	public Page<Coupon> findCouponByProject(Page<Coupon> page, int projectId) {
		
		return couponDao.findCouponByProject(page, projectId);
	}

	@Override
	public Coupon getCouponByNo(String no) {
		
		return couponDao.getCouponByNo(no);
	}

	@Override
	public Page<Coupon> findCouponPageByProject(Page<Coupon> page, String by, String value, int ProjectId) {
		
		return couponDao.findCouponByProject(page, by, value, ProjectId);
	}

	@Override
	public Page<Coupon> findCouponByValue(Page<Coupon> page, String by, String value) {
		
		return couponDao.findCouponByValue(page, by, value);
	}

	@Override
	public Page<Coupon> findCouponByProjectId(Page<Coupon> page, int ProjectId) {
		return couponDao.findCouponByProjectId(page, ProjectId);
	}
}
